import ZYRequest from "./request";

const zyRequest = new ZYRequest({
  baseURL: "/api",
  timeout: 5000,

  // 定义当前请求的拦截器
  interceptors: {
    requestInterceptor: (config) => {
      console.log(config, "zyRequest的拦截器");
      // 让这个实例发送的请求都 带token
      // const token = localCache.getCache("token");
      // if (token) {
      //   config.headers.Authorization = `Bearer ${token}`;
      // }
      // console.log('请求成功')
      return config;
    },
    requestInterceptorCatch: (err) => {
      // console.log('请求失败')
      return err;
    },
    responseInterceptor: (response) => {
      // console.log('响应成功')
      return response;
    },
    responseInterceptorCatch: (err) => {
      // console.log('响应失败')
      return err;
    }
  }
});

export default zyRequest;
